//
//  BaseModel.m
//  MoGuRadio
//
//  Created by dlios on 15/6/6.
//  Copyright (c) 2015年 mogu.com 蘑菇科技. All rights reserved.
//

#import "BaseModel.h"

@implementation BaseModel

+ (NSString *)foucsChangeStringValue:(NSString *)string
{
    
    // 可变字符串（NSString不能增删改查，所以用可变字符串（NSMutableString）接收不可变字符串）
    NSMutableString *str1 = [NSMutableString stringWithFormat:@"%@", string];
    NSInteger count = str1.length;// 字符串长度
    
    if (count - 8 > 0) {
        NSRange range1 = {count - 8, 8};
        [str1 deleteCharactersInRange:range1];// 删除最后八位数
        NSMutableString *str2 = [NSMutableString stringWithFormat:@"%@", string];
        NSRange range2 = {count - 8, 1};// 取倒数第四位数（千位）
        NSString *str3 = [str2 substringWithRange:range2];
        
        return [NSString stringWithFormat:@"%@.%@亿", str1, str3];
    }
    
    if (count - 4 > 0 && count - 8 <= 0) {
        NSRange range1 = {count - 4, 4};
        [str1 deleteCharactersInRange:range1];// 删除最后四位数
        NSMutableString *str2 = [NSMutableString stringWithFormat:@"%@", string];
        NSRange range2 = {count - 4, 1};// 取倒数第四位数（千位）
        NSString *str3 = [str2 substringWithRange:range2];
        
        return [NSString stringWithFormat:@"%@.%@万人关注", str1, str3];
    }
    if (count - 4 == 0) {
        NSMutableString *str2 = [NSMutableString stringWithFormat:@"%@", string];
        NSRange range2 = {count - 4, 1};
        NSString *str3 = [str2 substringWithRange:range2];
        return [NSString stringWithFormat:@"%d.%@万人关注", 0, str3];
    }
    if (count - 4 < 0) {
        return [NSString stringWithFormat:@"%@人关注", string];// 点击量不过千直接写多少即可
    }
    return 0;
    
}


+ (NSString *)listenChangeStringValue:(NSString *)string
{
    
    // 可变字符串（NSString不能增删改查，所以用可变字符串（NSMutableString）接收不可变字符串）
    NSMutableString *str1 = [NSMutableString stringWithFormat:@"%@", string];
    NSInteger count = str1.length;// 字符串长度
    
    if (count - 4 > 0) {
        NSRange range1 = {count - 4, 4};
        [str1 deleteCharactersInRange:range1];// 删除最后四位数
        NSMutableString *str2 = [NSMutableString stringWithFormat:@"%@", string];
        NSRange range2 = {count - 4, 1};// 取倒数第四位数（千位）
        NSString *str3 = [str2 substringWithRange:range2];
        
        return [NSString stringWithFormat:@"%@.%@万次收听", str1, str3];
    }
    if (count - 4 == 0) {
        NSMutableString *str2 = [NSMutableString stringWithFormat:@"%@", string];
        NSRange range2 = {count - 4, 1};
        NSString *str3 = [str2 substringWithRange:range2];
        return [NSString stringWithFormat:@"%d.%@万次收听", 0, str3];
    }
    if (count - 4 < 0) {
        return [NSString stringWithFormat:@"%@人收听", string];// 点击量不过千直接写多少即可
 }
    return 0;
    
    
    
}

@end
